<template >
    <!-- header -->

    
    <div>
    <p>{{ message }}</p>
    
    
  </div>
  
</template>


<script>
export default {
  name: "Header",
  data() {
    return {
      message:"请登录以获取资源",
    };
  },
  mounted() {
    // 组件挂载完成后，执行异步请求资源的函数
    this.fetchResource();
  },
  methods: {
    fetchResource() {
      this.$axios
        .get("http://localhost:8080/api/test/admin", {
          headers: {
            Authorization: "Bearer " + localStorage.getItem("token"),
          }, // 携带 JWT
        })
        .then((res) => {
        //   console.log(res.data);
          this.$set(this, 'message', res.data);
        //   console.log(res);
        })
        .catch((error) => console.log(error));;
    }
  },
};
</script>

<style scoped>
</style>